library(fs)
# pull all .Rmd files from my blog
<- list.files(
files_rmd "~/livefreeordichotomize/content/post",
pattern = "*.Rmd")
# remove the .Rmd for the folders
<- gsub(".Rmd", "", files_rmd)
folders
# pull again, with full names
<- list.files(
full_files "~/livefreeordichotomize/content/post",
pattern = "*.Rmd",
full.names = TRUE)
# create folders
dir_create(glue::glue("posts/{folders}"))
# copy the .Rmd files into a new folder, named according to the old file name
::walk2(
purrr
full_files,
folders, ~file_copy(.x, glue::glue("posts/{.y}/index.qmd")))
Migrating from Hugo to Quarto
We have migrated our blog from Hugo to Quarto! Here are a few quick tips that made the transition a bit smoother.
1. Setting up a Quarto website
It is super easy to set up a Quarto website. To get the basic template, you can run the following in your terminal:
quarto create-project mysite --type website
You can find lots of details about how to customize your site in the Quarto Docs. The rest of this post will cover a few things that made the transition smooth for us.
2. Moving .Rmd files from Hugo to your new site
In Hugo, my .Rmd files were in the following folder under the main project: content/post
. These were often individual files, rather than nested in folders. For my Quarto site, I wanted them in a folder called post
and I wanted each post to have it’s only folder with content in a file called index.qmd
nested within. I wrote a quick R script to help me do this.
3. Setting up a 404 pages for readers with old links
Since we have rerouted where many of the files are, I set up a 404 page that will allow readers to quickly find a post if they have an old link. To do this, I created a folder in the top of the project called 404.qmd
containing the following:
---
title: Page Not Found
listing:
contents: posts
type: table
sort: "date"
---
This will create a searchable table listing of all of the previous posts, allowing readers to quickly find the link they are looking for.
UPDATE You can add the old links under an aliases
parameter in each posts’ YAML.
4. Comments and Google analytics
It is straightforward to incorporate comments on your blog – our old site used utterance. Likewise, it is simple to add Google Analytics. To use this in Quarto, we can add the following to the website’s global
yaml
:To see our full setup, check out our GitHub repo: github.com/LFOD/LFOD.github.io
Have other questions? Feel free to leave them in the comments!